<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master"%>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Assembly Name="Starznet.SharePoint.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eaf3f5a885a2d969" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="Starznet.SharePoint" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>
<%@ Register Tagprefix="Starznet" Namespace="Starznet.SharePoint.Controls.Web" Assembly="Starznet.SharePoint.SPDAT, Version=1.0.0.0, Culture=neutral, PublicKeyToken=74e3ac9236a77c47" %>
<asp:Content contentplaceholderid="PlaceHolderPageTitle" runat="server">
	<SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="<%$Resources:szadm,DevHelp_CType_PageTitle%>" EncodeMethod="HtmlEncode"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
	<SharePoint:EncodedLiteral ID="EncodedLiteral2" runat="server" text="<%$Resources:szadm,DevHelp_CType_PageTitle%>" EncodeMethod="HtmlEncode"/>
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageDescription" runat="server">
	<SharePoint:EncodedLiteral ID="EncodedLiteral3" runat="server" text="<%$Resources:szadm,DevHelp_CType_PageDesc%>" EncodeMethod="HtmlEncode"/>
</asp:Content>
<asp:Content ContentPlaceHolderID="PlaceHolderPageImage" runat="server">
	<a href="http://www.starznet.co.uk" title="Visit the Starznet website" target="_blank">
	    <img src="/_layouts/Starznet/StarznetPageGraphic.gif" alt="Starznet Ltd" style="margin-top:3px;border:0px;"/>
	</a>
</asp:Content>
<asp:Content id="CTContent4" runat="server" ContentPlaceHolderID="PlaceHolderMain">
    <script type="text/javascript">
        function ShowHide(name)
        {
            var o = document.getElementById('div_' + name);
            if(o.style.display == 'none')
                o.style.display = 'block';
            else
                o.style.display = 'none';
        }
        function CopyText(name)
        {
            var oHoldText = document.getElementById('txt_' + name);
            var oCopied;
                    
            oCopied = oHoldText.createTextRange();
            oCopied.execCommand("Copy");

        }
    </script>
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
	    <tr>
		    <td ID=mngfieldToobar>
			    <wssuc:ToolBar id="onetidMngFieldTB" runat="server">
				    <Template_Buttons>
					    <wssuc:ToolBarButton runat="server" Text="<%$Resources:wss,multipages_createbutton_text%>"
						    id="idAddField"
						    ToolTip="<%$Resources:wss,mngfield_AddField%>"
						    NavigateUrl="../ctypenew.aspx" ImageUrl="/_layouts/images/newitem.gif"
						    AccessKey="C" />
				    </Template_Buttons>
		            <Template_RightButtons></Template_RightButtons>
			    </wssuc:ToolBar>
		    </td>
	    </tr>
    </table>
    <%
        SPWeb oWeb = SPContext.Current.Site.RootWeb;
        SPContentTypeCollection oT = oWeb.ContentTypes;
        SPContentTypeId id = oT[0].Id;

        StringBuilder oSB = new StringBuilder();
        oSB.Append("<table style='font-size:10pt' border='0' cellpadding='2' width='100%'>");
        oSB.Append("<tr><td class='ms-vb2'>");
        oSB.Append("<li>");
        oSB.Append("<a style=\"cursor:hand;\" onclick=\"ShowHide('" + oT[0].Id.ToString() + "');\">");
        oSB.Append(oT[0].Name);
        oSB.Append("</a>&nbsp;");
        oSB.Append("<div id=\"div_" + oT[0].Id.ToString() + "\" style=\"width:100%;display:none;background-color:#f2f2f2;border:solid 1px #d4d0c8;\">");
        oSB.Append("<b>GUID: </b>" + oT[0].Id.ToString() + "</br>");
        oSB.Append("<b>XML Schema: </b>");
        oSB.Append("&nbsp;&nbsp;<a style=\"cursor:hand;\" onclick=\"CopyText('" + oT[0].Id.ToString() + "');\">copy</a><br />");
        oSB.Append("<div style=\"width:100%;overflow:auto;\" id=\"xml_" + oT[0].Id.ToString() + "\">");
        oSB.Append(Utility.TransformXML(oT[0].SchemaXml));
        oSB.Append("</div>");
        oSB.Append("<textarea id=\"txt_" + oT[0].Id.ToString() + "\" style=\"display:none;\">" + System.Web.HttpUtility.HtmlEncode(oT[0].SchemaXml) + "</textarea>");
        oSB.Append("</div>");
        oSB.Append("</li>");
        //Get this types children types
        this.ShowChildren(id, ref oSB, oWeb);
        oSB.Append("</td></tr>");
        oSB.Append("</table>");

        Response.Write(oSB.ToString());
    %>
</asp:Content>
<script runat="server">
public void ShowChildren(SPContentTypeId ID, ref StringBuilder SB, SPWeb web)
{
    SPContentTypeCollection oT = web.ContentTypes;

    SB.Append("<ul>");
    foreach (SPContentType oType in oT)
    {
        if (oType.Parent.Id == ID && oType.Parent.Id != oType.Id)
        {
            SB.Append("<li>");
            SB.Append("<a style=\"cursor:hand;\" onclick=\"ShowHide('" + oType.Id.ToString() + "');\">");
            SB.Append(oType.Name);
            SB.Append("</a>&nbsp;");
            SB.Append("<div id=\"div_" + oType.Id.ToString() + "\" style=\"width:100%;display:none;background-color:#f2f2f2;border:solid 1px #d4d0c8;\">");
            SB.Append("<b>GUID: </b>" + oType.Id.ToString() + "</br>");
            SB.Append("<b>XML Schema: </b>");
            SB.Append("&nbsp;&nbsp;<a style=\"cursor:hand;\" onclick=\"CopyText('" + oType.Id.ToString() + "');\">copy</a><br />");
            SB.Append("<div style=\"width:100%;overflow:auto;\" id=\"xml_" + oType.Id.ToString() + "\">");
            SB.Append(Utility.TransformXML(oType.SchemaXml));
            SB.Append("</div>");
            SB.Append("<textarea id=\"txt_" + oType.Id.ToString() + "\" style=\"display:none;\">" + System.Web.HttpUtility.HtmlEncode(oType.SchemaXml) + "</textarea>");
            SB.Append("</div>");
            SB.Append("</li>");
            this.ShowChildren(oType.Id, ref SB, web);
        }
    }
    SB.Append("</ul>");
}
</script>